package me.send.data.service.provider;

import java.util.Map;

import me.send.business.base.SendVariable;
import me.send.data.service.pojo.Feedback;

public class FeedbackProvider {

	// 提供批量删除功能 2015年7月6日17:03:01
	public String batch_delete(Map<String, Object> parameter) {
		String feedbackids = (String) parameter.get("feedbackids");
		String sql = "";
		if (feedbackids != null && !feedbackids.equals("")) {
			sql = "delete from feedback where feedbackid in (" + feedbackids
					+ ")";
		}
		return sql;
	}

	public String list_page(Map<String, Object> parameter) {
		// 获取 对象 查询对象 2015年6月23日17:34:01
		Feedback feedback = (Feedback) parameter.get(SendVariable.DATA);
		// 判断下面的字段 是否是null
		String sql = "select * from feedback where 1=1 and userid>0  ";
		if (feedback != null) {
			if (feedback.getText() != null && !feedback.getText().equals("")) {
				sql += " and text like '%" + feedback.getText()
						+ "%'";
			}
			if (feedback.getSystem() != null
					&& !feedback.getSystem().equals("")) {
				sql += " and system = #{DATA.system} ";
			}
		}
		sql += " limit #{PAGE.start},#{PAGE.rows} ";
		return sql;
	}
	
	public String list_broker_page(Map<String, Object> parameter) {
		// 获取 对象 查询对象 2015年6月23日17:34:01
		Feedback feedback = (Feedback) parameter.get(SendVariable.DATA);
		// 判断下面的字段 是否是null
		String sql = "select * from feedback,popuser where 1=1 and feedback.popid>0 and feedback.popid=popuser.popid ";
		if (feedback != null) {
			if (feedback.getText() != null && !feedback.getText().equals("")) {
				sql += " and text like '%" + feedback.getText()
						+ "%'";
			}
			if (feedback.getSystem() != null
					&& !feedback.getSystem().equals("")) {
				sql += " and system = #{DATA.system} ";
			}
		}
		sql += " limit #{PAGE.start},#{PAGE.rows} ";
		return sql;
	}

	public String count_broker(Map<String, Object> parameter) {
		// 获取 对象 查询对象 2015年6月23日17:34:01
		Feedback feedback = (Feedback) parameter.get(SendVariable.DATA);
		// 判断下面的字段 是否是null
		String sql = "select count(1) as total from feedback,popuser where 1=1 and feedback.popid>0 and feedback.popid=popuser.popid ";
		if (feedback != null) {
			if (feedback.getText() != null && !feedback.getText().equals("")) {
				sql += " and text like '%" + feedback.getText()
						+ "%'";
			}
			if (feedback.getSystem() != null
					&& !feedback.getSystem().equals("")) {
				sql += " and system = #{DATA.system} ";
			}
		}
		return sql;
	}
	
	public String count(Map<String, Object> parameter) {
		// 获取 对象 查询对象 2015年6月23日17:34:01
		Feedback feedback = (Feedback) parameter.get(SendVariable.DATA);
		// 判断下面的字段 是否是null
		String sql = "select count(1) as total from feedback where 1=1 and feedback.userid>0 ";
		if (feedback != null) {
			if (feedback.getText() != null && !feedback.getText().equals("")) {
				sql += " and text like '%" + feedback.getText()
						+ "%'";
			}
			if (feedback.getSystem() != null
					&& !feedback.getSystem().equals("")) {
				sql += " and system = #{DATA.system} ";
			}
		}
		return sql;
	}
}
